package com.t371.spring.service.impl;

import com.t371.spring.dao.PetDao;
import com.t371.spring.dao.impl.PetDaoImpl;
import com.t371.spring.entity.Pet;
import com.t371.spring.service.PetService;
import org.springframework.beans.factory.annotation.Autowired;


public class PetServiceImpl implements PetService {
    //依赖对象

    public void setPetDao(PetDao petDao) {
        this.petDao = petDao;
    }

    /*public PetServiceImpl(PetDao petDao) {
        this.petDao = petDao;
    }*/

    //依赖对象的创建
    //private PetDao petDao = new PetDaoImpl();


    public int addPet(Pet pet) {
        //依赖对象的使用
        return petDao.add(pet);
    }

    public Pet getPet(int id) {
        //依赖对象的使用
        return petDao.get(id);
    }

    @Override
    public boolean save(Pet pet) {
        return petDao.insert(pet)>0;
    }

    @Autowired
//    @Resource(type="petDaoImpl.class")
    private PetDao petDao;


}
